1. Field
The present invention generally relates to query optimization. And more particularly, to optimizing a query based on energy monetary cost.
2. Description of the Related Art
Databases are computerized information storage and retrieval systems. A relational database management system is a computer database management system (DBMS) that uses relational techniques for storing and retrieving data. The most prevalent type of database is the relational database, a tabular database in which data is defined such that it can be reorganized and accessed in a number of different ways. A distributed database is a database that can be dispersed or replicated among different points in a network. An object-oriented programming database is a database that is congruent with the data defined in object classes and subclasses.
Regardless of the particular architecture, a requesting entity (e.g., an application or the operating system) in a DBMS requests access to a specified database by issuing a database access request. Such requests may include, for instance, simple catalog lookup requests or transactions and combinations of transactions that operate to read, change and add specified records in the database. These requests are commonly made using high-level query languages such as the Structured Query Language (SQL) and application programming interfaces (API's) such as Java® Database Connectivity (JDBC). The term “query” denominates a set of commands for retrieving data from a stored database. Queries take the form of a command language, such as the Structured Query Language (SQL), that lets programmers and programs select, insert, update, find out the location of data, and so forth.
Generally speaking, any requesting entity can issue queries against data in a database. For example, software applications, operating systems, and, at the highest level, users may submit queries to the database. These queries may be predefined (i.e., hard coded as part of an application) or may be generated in response to input (e.g., user input). Once the query is submitted, the database may execute the query against the data in the database and return a query result to the requesting entity.
Often times, for a given query, the database may be capable of executing the query in many different ways, with each execution method returning the same query result. For example, a database may have two different methods of scanning a database table: a normal scan and a parallel scan. In this example, while both scans return the same data from the table, the parallel scan may return this data more quickly, but with increased power consumption. As such, if the increased execution time from using the normal scan is a non-factor, the database owner may prefer to avoid using the parallel scan in order to reduce power consumption.
Currently, methods exist for optimizing database queries and query execution in order to reduce power consumption. However, while these techniques may result in less power usage, they do not always result in reduced monetary cost. For example, in an example where power cost differs depending on the time of day, it may be less expensive to use the faster parallel scanning technique (and thus use more power) during a less expensive time period in order to avoid using power during a more expensive time period. Thus, while these known techniques may result in reduced power consumption, this benefit may come with an increased monetary cost.